<?php
	
	/**
	* @author Robbie Vasquez
 	* @author Matt Kennedy
 	*/

	
	//creating array for months of the year
	$month = array('01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December');
	
	//creating array for the number of days in each month 
	$date = array('1' => 31, '2' => 28, '3' => 31, '4' => 30, '5' => 31, '6' => 30, '7' => 31, '8' => 31, '9' => 30, '10' => 31, '11' => 30, '12' => 31);
	
?>

<!-- requiring the header and the navigation pages -->
<?php require('includes/header.php'); ?>
<?php require('includes/nav.php'); ?>
	
	<?php if(isset($errors)): ?>
		<div class="errors">
			<?php for($i = 0; $i < count($errors); $i++): ?>
				<?php echo $errors[$i]; ?>
			<?php endfor; ?>
		</div>
	<?php endif; ?>
	
	<!-- creating a form for users to add runs -->
	<form action="" method="post">	  
			<table class="form">
				<tr>
					<th colspan="2" style="font-size:14pt;">Add a Run</th>
				</tr>
			
				<tr>
				  <td>Date:</td>
				  <td>
				  		<select name="month" id="month">
							<option value="<?php echo date('m'); ?>"><?php echo date('F'); ?></option>
						<?php foreach($month as $num => $name): ?>
							<option value="<?php echo $num; ?>"><?php echo $name; ?></option>
						<?php endforeach; ?>
						</select>
						
						<select name="date" id="date">
							<option value="<?php echo date('j'); ?>"><?php echo date('j'); ?></option>
						<?php for($i = 1; $i < 32; $i++): ?>
							<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
						<?php endfor; ?>
						</select>
						
						<select name="year">
						<?php for($i = date('Y'); $i >= 2000; $i--): ?>
							<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
						<?php endfor; ?>
						</select>
				   </td>
				</tr>
				
				<tr>
				  <td>Duration of Run:</td>
				  <td>
				  	<select name="hours">
						<?php for($i = 0; $i < 11; $i++): ?>
							<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
						<?php endfor; ?>
					</select>
						:
					<select name="minutes">
						<?php for($i = 0; $i < 60; $i++): ?>
							<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
						<?php endfor; ?>
					</select>
						:
					<select name="seconds">
						<?php for($i = 0; $i < 60; $i++): ?>
							<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
						<?php endfor; ?>
					</select>
				  </td>
				</tr>
				
				<tr>
					<td colspan="2">
						If this was a normal route, choose one.
						<br />
						Otherwise, enter a distance.
					</td>
				</tr>
				
				<tr>
				  <td>Select a Route:</td>
				  <td>
				  	<select name="selectroute">
				  		<option value="">None</option>
						<?php
							mysql_connect('2006.ispace.ci.fsu.edu', 'rmv06d', 'zqgvht2m');
							mysql_select_db('runningrecords');
						
							$sql = "SELECT * FROM routes WHERE username='" . $_SESSION['username'] . "'";
							$result = mysql_query($sql) or die(mysql_error());
						?>
						<?php while($pull = mysql_fetch_array($result)): ?>
							<option value="<?php echo $pull['routeID']; ?>"><?php echo $pull['name']; ?></option>
						<?php endwhile; ?>
					</select>
					</td>
				</tr>
				
				<tr>
					<td>Distance:</td>
					<td>
						<input type="text" size="9" maxlength="10" name="distance" /><select name="unit">
						<option value="miles">Miles</option><option value="kilometers">Kilometers</option></select></td>
				</tr>
				
				<tr>
					<td colspan="2">
						Comments: <br />
						<textarea name="comments" rows="3" cols="25"></textarea>
					</td>
				</tr>
											
				<tr>
				  <td colspan="2" align="center"><input type="submit" value=" Add Run >>" /></td>
				</tr>
			  </table>
		</form>

		
<?php require('includes/footer.php'); ?>